import request from '@/utils/request'

//管理员启用账号
export const enableUserService = (id) =>
  request.put(`/web/admin/activeUser/${id}`)

//管理员禁用账号
export const disableUserService = (id) =>
  request.put(`/web/admin/banUser/${id}`)

//管理员分页查询全部启用中的用户
export const queryAllUserService = ({
  pageNo,
  pageSize,
  username,
  name,
  organization
}) => {
  const params = {
    pageNo,
    pageSize,
    username,
    name,
    organization
  }
  if (!params.username) delete params.username
  if (!params.name) delete params.name
  if (!params.organization) delete params.organization
  return request.get('/web/admin/getAll', {
    params: params
  })
}

//管理员分页查询全部被禁用的用户
export const queryAllBanUserService = ({
  pageNo,
  pageSize,
  username,
  name,
  organization
}) => {
  const params = {
    pageNo,
    pageSize,
    username,
    name,
    organization
  }
  if (!params.username) delete params.username
  if (!params.name) delete params.name
  if (!params.organization) delete params.organization
  return request.get('/web/admin/getAllDeleted', {
    params: params
  })
}
